<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #box {
            width: 300px;
            height: 300px;
            background-color: #6ff;
        }
    </style>
</head>

<body>
    <div id="box"></div>
</body>
<script>
    var box = document.getElementById("box");
    // onclick      鼠标单击 (按下,抬起来)
    // ondblclick   鼠标双击 (鼠标左键  按下,抬起来) 
    // onmousedown  鼠标按下
    // 事件出发时的鼠标按键  
    // button   0(左)   1(中)    2(右)    3(侧键)   4(侧键)
    // onmouseup    鼠标抬起 (左键 中键 右键 侧键 抬起时触发)
    // onmousemove  鼠标移动时 (鼠标在绑定事件的元素上移动时触发)
    // onmouseover  鼠标划入触发
    // onmouseout   鼠标划出触发

    // box.ondblclick = function(){
    //     box.style.background = "red";
    // }

    box.onmousedown = function (e) {
        box.style.background = "red";
        console.log(e.button);
    }

    box.onmouseup = function () {
        box.style.background = "#6ff";
    }

</script>

</html>